package com.saturn.action.highcharts;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.saturn.app.web.IAction;
import com.saturn.app.web.IView;
import com.saturn.app.web.view.JsonView;
import com.saturn.highcharts.Pie;

public class ListPieDatasAction implements IAction {

	@Override
	public IView execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		Pie ct1 = new Pie();
		ct1.setName("Firefox");
		ct1.setData("45.0");
		
		Pie ct2 = new Pie();
		ct2.setName("IE");
		ct2.setData("26.8");
		
		Pie ct3 = new Pie();
		ct3.setName("Chrome");
		ct3.setData("12.8");
		
		Pie ct4 = new Pie();
		ct4.setName("Safari");
		ct4.setData("8.5");
		
		Pie ct5 = new Pie();
		ct5.setName("Opera");
		ct5.setData("6.2");
		
		Pie ct6 = new Pie();
		ct6.setName("Others");
		ct6.setData("0.7");
		
		List<Pie> cts = new ArrayList<Pie>();
		cts.add(ct1);
		cts.add(ct2);
		cts.add(ct3);
		cts.add(ct4);
		cts.add(ct5);
		cts.add(ct6);
		return new JsonView(Pie.getPieJSON(cts));
	}
	
	@Override
	public String requestMapping() {
		return "/highcharts/listPieDatas.action";
	}

}
